package com.example.app;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;

import com.getcapacitor.JSObject;
import com.getcapacitor.NativePlugin;
import com.getcapacitor.Plugin;
import com.getcapacitor.PluginCall;
import com.getcapacitor.PluginMethod;

import java.util.Map;

@NativePlugin()
public class DownloadPlugin extends Plugin {

    @PluginMethod()
    public void download(PluginCall call) {
        String url = call.getString("url");
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.addCategory(Intent.CATEGORY_BROWSABLE);
        intent.setData(Uri.parse(url));
        getContext().startActivity(intent);
//        JSObject ret = new JSObject();
//        ret.put("success", true);
//        call.resolve(ret);
    }
}


